<%inherit file="network_base.html" />

<%block name="innav">
<li>${ _("Port Mapping") }</li>
</%block>

<%block name="submain">

%if portmapping_list:
<h2>${ _("Total Mapping Port: ") } ${ TOTAL }</h2>

<p>${ _("Binding Port Total: ") } ${ binding_total }</p>

% if binding_total:
<p><a class="btn" href="${ reverse_url('admin:network:portmapping') }?has_ip=true">${ _("Find All Binding Port") }</a></p>
% endif

<div>
  <table class="table table-striped">
    <thead>
      <tr>
        <th>${ _("ID") }</th>
        % if not gateway:
        <th>${ _("Gateway") }</th>
        % endif
        <th>${ _("Gateway Port") }</th>
        <th>${ _("Instance") }</th>
        <th>${ _("Instance IP") }</th>
        <th>${ _("Instance Port") }</th>
        <th>${ _("Updated") }</th>
      </tr>
    </thead>
    <tbody>
      %for P in portmapping_list:
      <tr>
        <td>${ P.id }</td>
        %if not gateway:
        <td>${ P.gateway.name }</td>
        %endif
        <td>${ P.gateway_port }</td>
        <td>
          % if P.ip and P.ip.instance_id:
          <a href="${ reverse_url('admin:instance:view') }?id=${ P.ip.instance_id }">${ P.ip.instance.name }</a>
          % endif
        </td>
        <td>
          % if P.ip:
          ${ P.ip.ip }
          % endif
        </td>
        <td>
          % if P.ip_port:
          ${ P.ip_port }
          % endif
        </td>
        <td>${ ftime(P.updated) }</td>
      </tr>
      %endfor
    </tbody>
  </table>

  ${ PAGE_HTML }
</div>

%else:
<div class="hero-unit">
  <p>${ _("Can not find any port mapping.") }</p>
</div>
%endif

</%block>
